import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:smart_devices/bruno/src/components/tabbar/normal/brn_tab_bar.dart';
import 'package:smart_devices/model/maintain_order.dart';
import 'package:smart_devices/model/spare_part.dart';

class MaintainInfoLogic extends GetxController with GetTickerProviderStateMixin {
  Rx<SparePartModel> details = Rx(
      SparePartModel(imgUrl: '', name: '', code: '', model: '', count: 0, change: 0, inventory: 0));
  Rx<MaintainOrderModel> order = Rx(MaintainOrderModel(
    title: '',
    orderNo: '',
    name: '',
    code: '',
    location: '',
    addTime: '',
  ));

  RxList<BadgeTab> tabs = RxList([]);

  late TabController tabController;

  @override
  void onInit() {
    super.onInit();
    tabs.add(BadgeTab(text: '保养工单'));
    tabs.add(BadgeTab(text: '保养明细'));
    tabs.add(BadgeTab(text: '工作量'));
    tabs.add(BadgeTab(text: '更换备件'));
    tabs.add(BadgeTab(text: '验证信息'));
    tabController = TabController(length: tabs.length, vsync: this);
    if (Get.arguments != null) {
      details.value = Get.arguments['details'] as SparePartModel;
      order.value = Get.arguments['order'] as MaintainOrderModel;
    }
  }

  @override
  void onClose() {
    super.onClose();
    tabController.dispose();
  }
}
